<?php
include('../../inc/global.inc');
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST[act_tj]){
$city_id=$_POST[city_id]?$_POST[city_id]:0;
$c_dj=$_POST[c_dj]?$_POST[c_dj]:0;
$job_tj=$_POST[job_tj]?$_POST[job_tj]:0;
$is_job=$_POST[is_job]?$_POST[is_job]:0;
mysql_query("insert into city (city_name,city_id,order_name,city_ping,c_dj,job_tj,is_job) values ('$_POST[city_name]','$city_id','$_POST[order_name]','$_POST[city_ping]','$c_dj','$job_tj','$is_job')");
echo "<script>location='".$_POST[url]."';</script>";
}
?>
<?php
if($_POST['act_xg']){
$city_id=$_POST[city_id]?$_POST[city_id]:0;
$c_dj=$_POST[c_dj]?$_POST[c_dj]:0;
$job_tj=$_POST[job_tj]?$_POST[job_tj]:0;
$is_job=$_POST[is_job]?$_POST[is_job]:0;
mysql_query("update city set city_name='$_POST[city_name]',city_id='$city_id',order_name='$_POST[order_name]',city_ping='$_POST[city_ping]',c_dj='$c_dj',job_tj='$job_tj',is_job='$is_job' where id='".$_POST['iid']."'");
echo "<script>location='".$_POST[url]."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">省份/城市&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
if($_GET[tj]){
?>
  <table width="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <form method="post" action="city_modify.php" onSubmit="return check()">
    <tr>
      <td height="30" colspan="2" align="center" bgcolor="#8DA8CF" style="padding-left:5px;">添加省份/城市</td>
    </tr>
    <tr>
      <td width="33%" height="30" align="center" bgcolor="#FFFFFF"><span style="padding-left:5px;">省份/城市名称</span> </td>
      <td width="67%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="city_name" type="text" id="city_name" size="18" maxlength="50"></td>
    </tr>
	<tr>
      <td width="33%" height="30" align="center" bgcolor="#FFFFFF"><span style="padding-left:5px;">省份/城市首字母</span> </td>
      <td width="67%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="order_name" type="text" id="order_name" size="18" maxlength="50"></td>
    </tr>
	<tr>
      <td width="33%" height="30" align="center" bgcolor="#FFFFFF"><span style="padding-left:5px;">拼音</span> </td>
      <td width="67%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="city_ping" type="text" id="city_ping" size="18" maxlength="50"></td>
    </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><select name="city_id">
  <option value="0" selected>--选择上级目录--</option>
  <?php
  $sql="select * from city where city_id=0";
  $rs=mysql_query($sql);
  while($row=mysql_fetch_array($rs)){
  ?><option value="<?=$row['id']?>" <?php if($_GET[id]==$row['id']){echo "selected";}?>><?=$row[city_name]?></option>
  <?php
         $sql2="select * from city where city_id='".$row['id']."' order by id asc";
		 $rs2=mysql_query($sql2);
		 while($row2=mysql_fetch_array($rs2)){
       ?><option value="<?=$row2['id']?>" <?php if($_GET[id]==$row2[id]){echo "selected";}?>>&nbsp;&nbsp;&nbsp;&nbsp;|--<?=$row2['city_name']?></option>
  <?php
  }}?>
      </select></td>
    </tr>
	<tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">等级</td>
	   <td bgcolor="#FFFFFF" style="padding-left:2px;">
	   <select name="c_dj" id="c_dj">
	      <option value="1">省份[1级]</option>
		  <option value="2">城市[2级]</option>
		  <option value="3">地区[3级]</option>
	   </select></td>
	</tr>
	<tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">招聘推荐</td>
	   <td bgcolor="#FFFFFF" style="padding-left:2px;">
	   <select name="job_tj" id="job_tj">
	      <option value="1">是</option>
		  <option value="0" selected="selected">否</option>
	   </select></td>
	</tr>
	<tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">招聘开通城市</td>
	   <td bgcolor="#FFFFFF" style="padding-left:2px;">
	   <select name="is_job" id="is_job">
	      <option value="1">是</option>
		  <option value="0" selected="selected">否</option>
	   </select></td>
	</tr>
    <tr>
	<input type="hidden" name="act_tj" value="ok"><input type="hidden" name="url" value="<?=$url?>">
      <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
	</form>
  </table>
  <?php
}
?>
  <?php
if($_GET['xg']){
$sql="select * from city where id=".$_GET['xg_id'];
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs)
?>
<table width="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="post" action="city_modify.php" onSubmit="return check()">
      <tr>
        <td height="30" colspan="2" align="center" bgcolor="#8DA8CF"><span style="padding-left:5px;">修改省份/城市</span></td>
      </tr>
      <tr>
        <td width="33%" height="30" align="center" bgcolor="#FFFFFF"><span style="padding-left:5px;">省份/城市名称</span></td>
        <td width="67%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="city_name" type="text" value="<?=$row[city_name]?>" size="18" maxlength="50"></td>
      </tr>
	<tr>
      <td width="33%" height="30" align="center" bgcolor="#FFFFFF"><span style="padding-left:5px;">拼音</span> </td>
      <td width="67%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="city_ping" type="text" id="city_ping" size="18" maxlength="50" value="<?=$row[city_ping]?>"></td>
    </tr>
	 <tr>
      <td width="33%" height="30" align="center" bgcolor="#FFFFFF"><span style="padding-left:5px;">省份/城市首字母</span> </td>
      <td width="67%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="order_name" type="text" id="order_name" value="<?=$row[order_name]?>" size="18" maxlength="50"></td>
    </tr> 	
      <tr>
        <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
        <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
<select name="city_id">
   <option value="0">--选择上级目录--</option>
  <?php
  $sql2="select * from city where city_id=0 order by id asc";
  $rs2=mysql_query($sql2);
  while($row2=mysql_fetch_array($rs2)){
  ?>
    <option value="<?=$row2['id']?>" <?php if($row2[id]==$row[city_id]){echo "selected";}?>><?=$row2['city_name']?></option>
  <?php
         $sql3="select * from city where city_id='".$row2[id]."' order by id asc";
		 $rs3=mysql_query($sql3);
		 while($row3=mysql_fetch_array($rs3)){
       ?><option value="<?=$row3['id']?>" <?php if($row[city_id]==$row3[id]){echo "selected";}?>>&nbsp;&nbsp;&nbsp;&nbsp;|--<?=$row3[city_name]?></option>
 
 <?php
  }}?>
        </select></td>
      </tr>
	<tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">等级</td>
	   <td bgcolor="#FFFFFF" style="padding-left:2px;">
	   <select name="c_dj" id="c_dj">
	      <option value="1" <?php if($row[c_dj]==1){echo "selected";}?>>省份[1级]</option>
		  <option value="2" <?php if($row[c_dj]==2){echo "selected";}?>>城市[2级]</option>
		  <option value="3" <?php if($row[c_dj]==3){echo "selected";}?>>地区[3级]</option>
	   </select></td>
	</tr>
		<tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">招聘推荐</td>
	   <td bgcolor="#FFFFFF" style="padding-left:2px;">
	   <select name="job_tj" id="job_tj">
	      <option value="1" <?php if($row[job_tj]==1){echo "selected";}?>>是</option>
		  <option value="0" <?php if($row[job_tj]==0){echo "selected";}?>>否</option>
	   </select></td>
	</tr>
	<tr>
	   <td height="30" align="center" bgcolor="#FFFFFF">招聘开通城市</td>
	   <td bgcolor="#FFFFFF" style="padding-left:2px;">
	   <select name="is_job" id="is_job">
	      <option value="1" <?php if($row[is_job]==1){echo "selected";}?>>是</option>
		  <option value="0" <?php if($row[is_job]==0){echo "selected";}?>>否</option>
	   </select></td>
	</tr>
      <tr><input type="hidden" name="url" value="<?=$url?>">
        <input type="hidden" name="act_xg" value="ok"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" value="提交"></td>
      </tr>
    </form>
  </table>
  <?php
}?>
</center>
</BODY>
</HTML>
